import React from 'react'
import { Panel, PanelHeader, PanelBody, PanelFooter, Button } from 'react-weui'
import Item from './ShoppingCartItem'

export default class ShoppingCartList extends React.Component {
    constructor(props) {
        super(props)
        this.state = {
            goodsData:[],
            visible: true,
            // cleaned: false
        }
    }
    componentWillReceiveProps(nextProps) {
        // if(nextProps.shoppingCart.shoppingCart.isFetched == true) {
        //     this.setState({
        //         goodsData: nextProps.goodsData,
        //         visible: true
        //     })
        // }
        // else if(nextProps.shoppingCart.shoppingCart.isFetched == false) {
        //     this.setState({
        //         visible:false
        //     })
        // }

    }
	render() {
        const { goodsData } = this.props;
        const shoppingCart = this.props.shoppingCart;
		return (
            <Panel style={{ marginTop: '60px', marginBottom: '135px'}}>
                <PanelHeader>
                    所有商品
                </PanelHeader>
                <PanelBody>
                    <div>
                    {
                        goodsData.length>0?goodsData.map(function(item, i) {
                            return (
                                <Item
                                    shoppingCart={shoppingCart}
                                    key={i}
                                    name={item.goodsName}
                                    price={item.goodsPrice}
                                    num={item.goodsNum}
                                    thumb={item.goodsThumb}
                                    cartId={item.cartId}
                                    buyerId={item.buyerId}
                                    storeId={item.storeId}
                                    goodsId= {item.goodsId}
                                    sizeId= {item.sizeId}
                                    colorId= {item.colorId}
                                    storeName= {item.storeName}
                                 />
                            )
                        }):null
                    }
                    </div>
                </PanelBody>
               {/* <Button  style={{marginTop: '60px'}} type="primary" onClick={this.cleanShoppingCart.bind(this)}>清空购物车</Button>*/}
                <PanelFooter href="javascript:void(0);" >
            </PanelFooter>
        </Panel>
		);
	}
}
